package com.authine.cloudpivot.ext.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
 * @author Administrator
 */
@Data
@Schema(description = "Page")

public class Page {
    @Schema(description = "pageIndex")
    private Integer pageIndex;
    @Schema(description = "pageSize")
    private Integer pageSize;

    public Page() {
    }

    public Page(Integer pageIndex, Integer pageSize) {
        this.pageIndex = pageIndex;
        this.pageSize = pageSize;
    }

    public String limit() {
        if (pageIndex == null) {
            pageIndex = 0;
        }
        if (pageSize == null) {
            pageSize = 10;
        }
        return String.format(" limit %s,%s", pageIndex > 0 ? (pageIndex - 1) * pageSize : 0, pageSize);
    }

}





